package cn.z2huo.knowledge.designpattern.simplefactory.example;

class OperationFactory {

    public static Operation createOperate(String operate) {
        return switch (operate) {
            case "+" -> new OperationAdd();
            case "-" -> new OperationSubtract();
            case "*" -> new OperationMultiply();
            case "/" -> new OperationDivide();
            default -> null;
        };
    }

    public static void main(String[] args) {
        Operation operation = OperationFactory.createOperate("+");
        operation.setNumberA(10);
        operation.setNumberB(20);
        System.out.println(operation.getResult());
    }

}
